import Vue from 'vue'
import Vuex from 'vuex'
import { getItem,setItem } from "@/untils/storage";
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token:getItem('token'),
    user:getItem('user')
  },
  mutations: {
    //token是用来接收后端传递过来的信息
    setUserToken(state,token){
      state.token=token
      // 将传递过来的用户数据缓存到本地
      setItem('token',state.token)
    },
    setUserInfo(state,user){
      state.user =user
      setItem('user',state.user)
    }
  },
  actions: {
  },
  modules: {
  }
})
